package me.lovatcat.springboot.demo.vo;

import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 直接在application配置文件中添加属性，通过ConfigurationProperties注解prefix=xxx方式
 * 引入前缀为xxx的配置信息
 *
 * @author acat on 2017-01-12 13:44
 */
@Component
@ConfigurationProperties(prefix = "author")
public class Author {

    //还可以对配置参数进行校验，如果校验不通过则系统启动时就会报错
    @NotEmpty
    private String name;

    private int age;

    @NotNull
    private String sex;

    private String password;

    private List<String> sons;

    private List<String> opus;

    private String petCat;

    private String petDog;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public List<String> getSons() {
        return sons;
    }

    public void setSons(List<String> sons) {
        this.sons = sons;
    }

    public String getPetCat() {
        return petCat;
    }

    public void setPetCat(String petCat) {
        this.petCat = petCat;
    }

    public String getPetDog() {
        return petDog;
    }

    public void setPetDog(String petDog) {
        this.petDog = petDog;
    }

    public List<String> getOpus() {
        return opus;
    }

    public void setOpus(List<String> opus) {
        this.opus = opus;
    }

    @Override
    public String toString() {
        return "Author{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", sex='" + sex + '\'' +
                ", password='" + password + '\'' +
                ", sons=" + sons +
                ", opus=" + opus +
                ", petCat='" + petCat + '\'' +
                ", petDog='" + petDog + '\'' +
                '}';
    }
}
